home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / GCC 1.37.1r14 / usr / gcc-1.37.1r14 / (gcc-1.37.π) / expmed.c < prev    next >
Encoding:
Text File  |  1993-07-01  |  51.7 KB  |  1,113 lines  |  [TEXT/KAHL]

  1. /* Medium-level subroutines: convert bit-field store and extract
  2.    and shifts, multiplies and divides to rtl instructions.
  3.    Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 1, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANt word or byte containing part of the field.  */
  14.  
  15.   if (GET_CODE (op0) == REG)
  16.     {
  17.       if (offset != 0
  18.       || GET_MODE_SIZE (GET_MODE (op0)) > GET_MODE_SIZE (SImode))
  19.     op0 = gen_rtx (SUBREG, SImode, op0, offset);
  20.       offset = 0;
  21.     }
  22.   else
  23.     {
  24.       op0 = protect_from_queue (op0, 1);
  25.     }
  26.  
  27.   /* Now OFFSET is nonzero only if OP0 is memory
  28.      and is therefore always measured in bytes.  */
  29.  
  30. #ifdef HAVE_insv
  31.   if (HAVE_insv
  32.       && !(bitsize == 1 && GET_CODE (value) == CONST_INT))
  33.     {
  34.       int xbitpos = bitpos;
  35.       rtx xop0 = op0;
  36.       rtx last = get_last_insn ();
  37.       rtx pat;
  38.  
  39.       /* If this machine's insv can only insert into a register,
  40.      copy OP0 into a register and save it back later.  */
  41.       if (GET_CODE (op0) == MEM
  42.       && ! (*insn_operand_predicate[(int) CODE_FOR_insv][0]) (op0, VOIDmode))
  43.     {
  44.       rtx tempreg;
  45.       enum machine_mode trymode, bestmode = VOIDmode, insn_mode;
  46.       int maxsize = GET_MODE_SIZE (insn_operand_mode[(int) CODE_FOR_insv][0]);
  47.  
  48.       /* Find biggest machine mode we can safely use
  49.          to fetch from this structure.
  50.          But don't use a bigger mode than the insn wants.  */
  51.       for (trymode = QImode;
  52.            trymode && GET_MODE_SIZE (trymode) <= maxsize;
  53.            trymode = GET_MODE_WIDER_MODE (trymode))
  54.         if (GET_MODE_SIZE (trymode) <= align)
  55.           bestmode = trymode;
  56.       if (! bestmode)
  57.         abort ();
  58.       /* Adjust address to point to the containing unit of that mode.  */
  59.       unit = GET_MODE_BITSIZE (bestmode);
  60.       /* Compute offset as multiple of this unit, counting in bytes.  */
  61.       offset = (bitnum / unit) * GET_MODE_SIZE (bestmode);
  62.       bitpos = bitnum % unit;
  63.       op0 = change_address (op0, bestmode, 
  64.                 plus_constant (XEXP (op0, 0), offset));
  65.  
  66.       /* Fetch that unit, store the bitfield in it, then store the unit.  */
  67.       tempreg = copy_to_reg (op0);
  68.       /* To actually store in TEMPREG,
  69.          look at it in the mode this insn calls for.
  70.          (Probably SImode.)  */
  71.       insn_mode = insn_operand_mode[(int) CODE_FOR_insv][0];
  72. #ifdef BITS_BIG_ENDIAN
  73.       if (GET_MODE_BITSIZE (insn_mode) > unit)
  74.         bitpos += GET_MODE_BITSIZE (insn_mode) - unit;
  75. #endif
  76.       store_bit_field (gen_rtx (SUBREG, insn_mode, tempreg, 0),
  77.                bitsize, bitpos, fieldmode, value, align);
  78.       emit_move_insn (op0, tempreg);
  79.       return value;
  80.     }
  81.  
  82.       /* Add OFFSET into OP0's address.  */
  83.       if (GET_CODE (xop0) == MEM)
  84.     xop0 = change_address (xop0, QImode,
  85.                    plus_constant (XEXP (xop0, 0), offset));
  86.  
  87.       /* If xop0 is a register, we need it in SImode
  88.      to make it acceptable to the format of insv.  */
  89.       if (GET_CODE (xop0) == SUBREG)
  90.     PUT_MODE (xop0, SImode);
  91.       if (GET_CODE (xop0) == REG && GET_MODE (xop0) != SImode)
  92.     xop0 = gen_rtx (SUBREG, SImode, xop0, 0);
  93.  
  94.       /* Convert VALUE to SImode (which insv insn wants) in VALUE1.  */
  95.       value1 = value;
  96.       if (GET_MODE (value) != SImode)
  97.     {
  98.       if (GET_MODE_BITSIZE (GET_MODE (value)) >= bitsize)
  99.         {
  100.           /* Optimization: Don't bother really extending VALUE
  101.          if it has all the bits we will actually use.  */
  102.  
  103.           /* Avoid making subreg of a subreg, or of a mem.  */
  104.           if (GET_CODE (value1) != REG)
  105.         value1 = copy_to_reg (value1);
  106.           value1 = gen_rtx (SUBREG, SImode, value1, 0);
  107.         }
  108.       else if (!CONSTANT_P (value))
  109.         /* Parse phase is supposed to make VALUE's data type
  110.            match that of the component reference, which is a type
  111.            at least as wide as the field; so VALUE should have
  112.            a mode that corresponds to that type.  */
  113.         abort ();
  114.     }
  115.  
  116.       /* If this machine's insv insists on a register,
  117.      get VALUE1 into a register.  */
  118.       if (! (*insn_operand_predicate[(int) CODE_FOR_insv][3]) (value1, SImode))
  119.     value1 = force_reg (SImode, value1);
  120.  
  121.       /* On big-endian machines, we count bits from the most significant.
  122.      If the bit field insn does not, we must invert.  */
  123.  
  124. #if defined (BITS_BIG_ENDIAN) != defined (BYTES_BIG_ENDIAN)
  125.       xbitpos = unit - 1 - xbitpos;
  126. #endif
  127.  
  128.       pat = gen_insv (xop0,
  129.               gen_rtx (CONST_INT, VOIDmode, bitsize),
  130.               gen_rtx (CONST_INT, VOIDmode, xbitpos),
  131.               value1);
  132.       if (pat)
  133.     emit_insn (pat);
  134.       else
  135.         {
  136.       delete_insns_since (last);
  137.       store_fixed_bit_field (op0, offset, bitsize, bitpos, value, align);
  138.     }
  139.     }
  140.   else
  141. #endif
  142.     /* Insv is not available; store using shifts and boolean ops.  */
  143.     store_fixed_bit_field (op0, offset, bitsize, bitpos, value, align);
  144.   return value;
  145. }
  146.  
  147. /* Use shifts and boolean operations to store VALUE
  148.    into a bit field of width BITSIZE
  149.    in a memory location specified by OP0 except offset by OFFSET bytes.
  150.      (OFFSET must be 0 if OP0 is a register.)
  151.    The field starts at position BITPOS within the byte.
  152.     (If OP0 is a register, it may be SImode or a narrower mode,
  153.      but BITPOS still counts within a full word,
  154.      which is significant on bigendian machines.)
  155.    STRUCT_ALIGN is the alignment the structure is known to have (in bytes).
  156.  
  157.    Note that protect_from_queue has already been done on OP0 and VALUE.  */
  158.  
  159. static void
  160. store_fixed_bit_field (op0, offset, bitsize, bitpos, value, struct_align)
  161.      register rtx op0;
  162.      register int offset, bitsize, bitpos;
  163.      register rtx value;
  164.      int struct_align;
  165. {
  166.   register enum machine_mode mode;
  167.   int total_bits = BITS_PER_WORD;
  168.   rtx subtarget;
  169.   int all_zero = 0;
  170.   int all_one = 0;
  171.  
  172.   /* Add OFFSET to OP0's address (if it is in memory)
  173.      and if a single byte contains the whole bit field
  174.      change OP0 to a byte.  */
  175.  
  176.   /* There is a case not handled here:
  177.      a structure with a known alignment of just a halfword
  178.      and a field split across two aligned halfwords within the structure.
  179.      Or likewise a structure with a known alignment of just a byte
  180.      and a field split across two bytes.
  181.      Such cases are not supposed to be able to occur.  */
  182.  
  183.   if (GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG)
  184.     {
  185.       if (offset != 0)
  186.     abort ();
  187.       /* Special treatment for a bit field split across two registers.  */
  188.       if (bitsize + bitpos > BITS_PER_WORD)
  189.     {
  190.       store_split_bit_field (op0, bitsize, bitpos, value, BITS_PER_WORD);
  191.       return;
  192.     }
  193.     }
  194.   else if (bitsize + bitpos <= BITS_PER_UNIT
  195.        && (! SLOW_BYTE_ACCESS
  196.            || (struct_align == 1
  197.            && BIGGEST_ALIGNMENT > 1)))
  198.     {
  199.       /* It fits in one byte, and either bytes are fast
  200.      or the alignment won't let us use anything bigger.  */
  201.       total_bits = BITS_PER_UNIT;
  202.       op0 = change_address (op0, QImode, 
  203.                 plus_constant (XEXP (op0, 0), offset));
  204.     }
  205.   else if ((bitsize + bitpos + (offset % GET_MODE_SIZE (HImode)) * BITS_PER_UNIT
  206.         <= GET_MODE_BITSIZE (HImode))
  207.        /* If halfwords are fast, use them whenever valid.  */
  208.        && (! SLOW_BYTE_ACCESS
  209.            /* Use halfwords if larger is invalid due to alignment.  */
  210.            || (struct_align == GET_MODE_SIZE (HImode)
  211.            && BIGGEST_ALIGNMENT > GET_MODE_SIZE (HImode))))
  212.     {
  213.       /* It fits in an aligned halfword within the structure,
  214.      and either halfwords are fast
  215.      or the alignment won't let us use anything bigger.  */
  216.       total_bits = GET_MODE_BITSIZE (HImode);
  217.  
  218.       /* Get ref to halfword containing the field.  */
  219.       bitpos += (offset % (total_bits / BITS_PER_UNIT)) * BITS_PER_UNIT;
  220.       offset -= (offset % (total_bits / BITS_PER_UNIT));
  221.       op0 = change_address (op0, HImode, 
  222.                 plus_constant (XEXP (op0, 0), offset));
  223.     }
  224.   else
  225.     {
  226.       /* Get ref to an aligned word containing the field.  */
  227.       /* Adjust BITPOS to be position within a word,
  228.      and OFFSET to be the offset of that word.
  229.      Then alter OP0 to refer to that word.  */
  230.       bitpos += (offset % (BITS_PER_WORD / BITS_PER_UNIT)) * BITS_PER_UNIT;
  231.       offset -= (offset % (BITS_PER_WORD / BITS_PER_UNIT));
  232.       op0 = change_address (op0, SImode,
  233.                 plus_constant (XEXP (op0, 0), offset));
  234.  
  235.       /* Special treatment for a bit field split across two aligned words.  */
  236.       if (bitsize + bitpos > BITS_PER_WORD)
  237.     {
  238.       store_split_bit_field (op0, bitsize, bitpos, value, struct_align);
  239.       return;
  240.     }
  241.     }
  242.  
  243.   mode = GET_MODE (op0);
  244.  
  245.   /* Now MODE is either QImode, HImode or SImode for a MEM as OP0,
  246.      or is SImode for a REG as OP0.  TOTAL_BITS corresponds.
  247.      Theeld.  */
  248.       if (GET_CODE (xop0) == MEM)
  249.         {
  250.           if (! ((*insn_operand_predicate[(int) CODE_FOR_extv][1])
  251.              (xop0, GET_MODE (xop0))))
  252.         {
  253.           enum machine_mode bestmode = VOIDmode, trymode;
  254.           int maxsize = GET_MODE_SIZE (insn_operand_mode[(int) CODE_FOR_extzv][1]);
  255.  
  256.           /* Find biggest machine mode we can safely use
  257.              to fetch from this structure.
  258.              But don't use a bigger mode than the insn wants.  */
  259.           for (trymode = QImode;
  260.                trymode && GET_MODE_SIZE (trymode) <= maxsize;
  261.                trymode = GET_MODE_WIDER_MODE (trymode))
  262.             if (GET_MODE_SIZE (trymode) <= align)
  263.               bestmode = trymode;
  264.           if (! bestmode)
  265.             abort ();
  266.           unit = GET_MODE_BITSIZE (bestmode);
  267.  
  268.           /* Compute offset as multiple of this unit,
  269.              counting in bytes.  */
  270.           xoffset = (bitnum / unit) * GET_MODE_SIZE (bestmode);
  271.           xbitpos = bitnum % unit;
  272.           xop0 = change_address (xop0, bestmode,
  273.                      plus_constant (XEXP (xop0, 0),
  274.                             xoffset));
  275.           /* Fetch it to a register in that size.  */
  276.           xop0 = force_reg (bestmode, xop0);
  277.  
  278.           /* Now ref the register in the mode extv wants.  */
  279.           if (bestmode != insn_operand_mode[(int) CODE_FOR_extv][1])
  280.             xop0 = gen_rtx (SUBREG, insn_operand_mode[(int) CODE_FOR_extv][1],
  281.                     xop0, 0);
  282. #ifdef BITS_BIG_ENDIAN
  283.           if (GET_MODE_BITSIZE (GET_MODE (xop0)) > unit)
  284.             xbitpos += GET_MODE_BITSIZE (GET_MODE (xop0)) - unit;
  285. #endif
  286.         }
  287.           else
  288.         xop0 = change_address (xop0, QImode,
  289.                        plus_constant (XEXP (xop0, 0), xoffset));
  290.         }
  291.  
  292.       /* If op0 is a register, we need it in SImode
  293.          to make it acceptable to the format of extv.  */
  294.       if (GET_CODE (xop0) == SUBREG && GET_MODE (xop0) != SImode)
  295.         abort ();
  296.       if (GET_CODE (xop0) == REG && GET_MODE (xop0) != SImode)
  297.         xop0 = gen_rtx (SUBREG, SImode, xop0, 0);
  298.  
  299.       if (xtarget == 0
  300.           || (flag_force_mem && GET_CODE (xtarget) == MEM))
  301.         xtarget = xspec_target = gen_reg_rtx (tmode);
  302.  
  303.       if (GET_MODE (xtarget) != SImode)
  304.         {
  305.           if (GET_CODE (xtarget) == REG)
  306.         xspec_target_subreg = xtarget = gen_lowpart (SImode, xtarget);
  307.           else
  308.         xtarget = gen_reg_rtx (SImode);
  309.         }
  310.  
  311.       /* If this machine's extv insists on a register target,
  312.          make sure we have one.  */
  313.       if (! (*insn_operand_predicate[(int) CODE_FOR_extv][0]) (xtarget, SImode))
  314.         xtarget = gen_reg_rtx (SImode);
  315.  
  316.       /* On big-endian machines, we count bits from the most significant.
  317.          If the bit field insn does not, we must invert.  */
  318. #if defined (BITS_BIG_ENDIAN) != defined (BYTES_BIG_ENDIAN)
  319.       xbitpos = unit - 1 - xbitpos;
  320. #endif
  321.  
  322.       bitsize_rtx = gen_rtx (CONST_INT, VOIDmode, bitsize);
  323.       bitpos_rtx = gen_rtx (CONST_INT, VOIDmode, xbitpos);
  324.  
  325.       pat = gen_extv (protect_from_queue (xtarget, 1),
  326.               xop0, bitsize_rtx, bitpos_rtx);
  327.       if (pat)
  328.         {
  329.           emit_insn (pat);
  330.           target = xtarget;
  331.           spec_target = xspec_target;
  332.           spec_target_subreg = xspec_target_subreg;
  333.         }
  334.       else
  335.         {
  336.           delete_insns_since (last);
  337.           target = extract_fixed_bit_field (tmode, op0, offset, bitsize,
  338.                         bitpos, target, 0, align);
  339.         }
  340.     } 
  341.       else
  342. #endif
  343.     target = extract_fixed_bit_field (tmode, op0, offset, bitsize, bitpos,
  344.                       target, 0, align);
  345.     }
  346.   if (target == spec_target)
  347.     return target;
  348.   if (target == spec_target_subreg)
  349.     return spec_target;
  350.   if (GET_MODE (target) != tmode && GET_MODE (target) != mode)
  351.     return convert_to_mode (tmode, target, unsignedp);
  352.   return target;
  353. }
  354.  
  355. /* Extract a bit field using shifts and boolean operations
  356.    Returns an rtx to represent the value.
  357.    OP0 addresses a register (word) or memory (byte).
  358.    BITPOS says which bit within the word or byte the bit field starts in.
  359.    OFFSET says how many bytes farther the bit field starts;
  360.     it is 0 if OP0 is a register.
  361.    BITSIZE says how many bits long the bit field is.
  362.     (If OP0 is a register, it may be narrower than SImode,
  363.      but BITPOS still counts within a full word,
  364.      which is significant on bigendian machines.)
  365.  
  366.    UNSIGNEDP is nonzero for an unsigned bit field (don't sign-extend value).
  367.    If TARGET is nonzero, attempts to store the value there
  368.    and return TARGET, but this is not guaranteed.
  369.    If TARGET is not used, create a pseudo-reg of mode TMODE for the value.
  370.  
  371.    ALIGN is the alignment that STR_RTX is known to have, measured in bytes.  */
  372.  
  373. static rtx
  374. extract_fixed_bit_field (tmode, op0, offset, bitsize, bitpos,
  375.              target, unsignedp, align)
  376.      enum machine_mode tmode;
  377.      register rtx op0, target;
  378.      register int offset, bitsize, bitpos;
  379.      int unsignedp;
  380.      int align;
  381. {
  382.   int total_bits = BITS_PER_WORD;
  383.   enum machine_mode mode;
  384.  
  385.   if (GET_CODE (op0) == SUBREG || GET_CODE (op0) == REG)
  386.     {
  387.       /* Special treatment for a bit field split across two registers.  */
  388.       if (bitsize + bitpos > BITS_PER_WORD)
  389.     return extract_split_bit_field (op0, bitsize, bitpos,
  390.                     unsignedp, align);
  391.     }
  392.   else if (bitsize + bitpos <= BITS_PER_UNIT
  393.        && (! SLOW_BYTE_ACCESS
  394.            || (align == 1
  395.            && BIGGEST_ALIGNMENT > 1)))
  396.     {
  397.       /* It fits in one byte, and either bytes are fast
  398.      or the alignment won't let us use anything bigger.  */
  399.       total_bits = BITS_PER_UNIT;
  400.       op0 = change_address (op0, QImode, 
  401.                 plus_constant (XEXP (op0, 0), offset));
  402.     }
  403.   else if ((bitsize + bitpos + (offset % GET_MODE_SIZE (HImode)) * BITS_PER_UNIT
  404.         <= GET_MODE_BITSIZE (HImode))
  405.        /* If halfwords are fast, use them whenever valid.  */
  406.        && (! SLOW_BYTE_ACCESS
  407.            /* Use halfwords if larger is invalid due to alignment.  */
  408.            || (align == GET_MODE_SIZE (HImode)
  409.            && BIGGEST_ALIGNMENT > GET_MODE_SIZE (HImode))))
  410.     {
  411.       /* It fits in an aligned halfword, and either halfwords are fast
  412.      or the alignment won't let us use anything bigger.  */
  413.       total_bits = GET_MODE_BITSIZE (HImode);
  414.  
  415.       /* Get ref to halfword containing the field.  */
  416.       bitpos += (offset % (total_bits / BITS_PER_UNIT)) * BITS_PER_UNIT;
  417.       offset -= (offset % (total_bits / BITS_PER_UNIT));
  418.       op0 = change_address (op0, HImode, 
  419.                 plus_constant (XEXP (op0, 0), offset));
  420.     }
  421.   else
  422.     {
  423.       /* Get ref to word containing the field.  */
  424.       /* Adjust BITPOS to be position within a word,
  425.      and OFFSET to be the offset of that word.  */
  426.       bitpos += (offset % (BITS_PER_WORD / BITS_PER_UNIT)) * BITS_PER_UNIT;
  427.       offset -= (offset % (BITS_PER_WORD / BITS_PER_UNIT));
  428.       op0 = change_address (op0, SImode,
  429.                 plus_constant (XEXP (op0, 0), offset));
  430.  
  431.       /* Special treatment for a bit field split across two words.  */
  432.       if (bitsize + bitpos > BITS_PER_WORD)
  433.     return extract_split_bit_field (op0, bitsize, bitpos,
  434.                     unsignedp, align);
  435.     }
  436.  
  437.   mode = GET_MODE (op0);
  438.  
  439. #ifdef BYTES_BIG_ENDIAN
  440.   /* BITPOS is the distance between our msb and that of OP0.
  441.      Convert it to the distance from the lsb.  */
  442.  
  443.   bitpos = total_bits - bitsize - bitpos;
  444. #endif
  445.   /* Now BITPOS is always the distance between the field's lsb and that of OP0.
  446.      We have reduced the big-endian case to the little-endian case.  */
  447.  
  448.   if (unsignedp)
  449.     {
  450.       if (bitpos)
  451.     {
  452.       /* If the field does not already start at the lsb,
  453.          shift it so it does.  */
  454.       tree amount = build_int_2 (bitpos, 0);
  455.       /* Maybe propagate the target for the shift.  */
  456.       /* But not if we will return it--could confuse integrate.c.  */
  457.       rtx subtarget = (target != 0 && GET_CODE (target) == REG
  458.                && !REG_FUNCTION_VALUE_P (target)
  459.                ? target : 0);
  460.       if (tmode != mode) subtarget = 0;
  461.       op0 = expand_shift (RSHIFT_EXPR, mode, op0, amount, subtarget, 1);
  462.     }
  463.       /* Convert the value to the desired mode.  */
  464.       if (mode != tmode)
  465.     op0 = convert_to_mode (tmode, op0, 1);
  466.  
  467.       /* Unless the msb of the field used to be the msb when we shifted,
  468.      mask out the upper bits.  */
  469.  
  470.       if ((GET_MODE_BITSIZE (mode) != bitpos + bitsize
  471. #if 0
  472. #ifdef SLOW_ZERO_EXTEND
  473.        /* Always generate an `and' if
  474.           we just zero-extended op0 and SLOW_ZERO_EXTEND, since it
  475.           will combine fruitfully with the zero-extend. */
  476.        || tmode != mode
  477. #endif
  478. #endif
  479.        )
  480.       && bitsize < HOST_BITS_PER_INT)
  481.     return expand_bit_and (GET_MODE (op0), op0,
  482.                    gen_rtx (CONST_INT, VOIDmode, (1 << bitsize) - 1),
  483.                    target);
  484.       return op0;
  485.     }
  486.  
  487.   /* To extract a signed bit-field, first shift its msb to the msb of the word,
  488.      then arithmetic-shift its lsb to the lsb of the word.  */
  489.   op0 = force_reg (mode, op0);
  490.   if (mode != tmode)
  491.     target = 0;
  492.   if (GET_MODE_BITSIZE (QImode) < GET_MODE_BITSIZE (mode)
  493.       && GET_MODE_BITSIZE (QImode) >= bitsize + bitpos)
  494.     mode = QImode, op0 = convert_to_mode (QImode, op0, 0);
  495.   if (GET_MODE_BITSIZE (HImode) < GET_MODE_BITSIZE (mode)
  496.       && GET_MODE_BITSIZE (HImode) >= bitsize + bitpos)
  497.     mode = HImode, op0 = convert_to_mode (HImode, op0, 0);
  498.   if (GET_MODE_BITSIZE (mode) != (bitsize + bitpos))
  499.     {
  500.       tree amount = build_int_2 (GET_MODE_BITSIZE (mode) - (bitsize + bitpos), 0);
  501.       /* Maybe propagate the target for the shift.  */
  502.       /* But not if we will return the result--could confuse integrate.c.  */
  503.       rtx subtarget = (target != 0 && GET_CODE (target) == REG
  504.                && ! REG_FUNCTION_VALUE_P (target)
  505.                ? target : 0);
  506.       op0 = expand_shift (LSHIFT_EXPR, mode, op0, amount, subtarget, 1);
  507.     }
  508.  
  509.   return expand_shift (RSHIFT_EXPR, mode, op0,
  510.                build_int_2 (GET_MODE_BITSIZE (mode) - bitsize, 0), 
  511.                target, 0);
  512. }
  513.  
  514. /* Extract a bit field that is split across two words
  515.    and return an RTX for the result.
  516.  
  517.    OP0 is the REG, SUBREG or MEM rtx for the first of the two words.
  518.    BITSIZE is the field width; BITPOS, position of its first bit, in the word.
  519.    UNSIGNEDP is 1 if should zero-extend the contents; else sign-extend.  */
  520.  
  521. static rtx
  522. extract_split_bit_field (op0, bitsize, bitpos, unsignedp, align)
  523.      rtx op0;
  524.      int bitsize, bitpos, unsignedp, align;
  525. {
  526.   /* BITSIZE_1 is size of the part in the first word.  */
  527.   int bitsize_1 = BITS_PER_WORD - bitpos;
  528.   /* BITSIZE_2 is size of the rest (in the following word).  */
  529.   int bitsize_2 = bitsize - bitsize_1;
  530.   rtx part1, part2, result;
  531.  
  532.   /* Get the part of the bit field from the first word.  */
  533.   part1 = extract_fixed_bit_field (SImode, op0, 0, bitsize_1, bitpos,
  534.                    0, 1, align);
  535.  
  536.   /* Offset op0 by 1 word to get to the following one.  */
  537.   if (GET_CODE (op0) == MEM)
  538.     op0 = change_address (op0, SImode,
  539.               plus_constant (XEXP (op0, 0), UNITS_PER_WORD));
  540.   else if (GET_CODE (op0) == REG)
  541.     op0 = gen_rtx (SUBREG, SImode, op0, 1);
  542.   else
  543.     op0 = gen_rtx (SUBREG, SImode, SUBREG_REG (op0), SUBREG_WORD (op0) + 1);
  544.  
  545.   /* Get the part of the bit field from the second word.  */
  546.   part2 = extract_fixed_bit_field (SImode, op0, 0, bitsize_2, 0, 0, 1, align);
  547.  
  548.   /* Shift the more significant part up to fit above the other part.  */
  549. #ifdef BYTES_BIG_ENDIAN
  550.   part1 = expand_shift (LSHIFT_EXPR, SImode, part1,
  551.             build_int_2 (bitsize_2, 0), 0, 1);
  552. #else
  553.   part2 = expand_shift (LSHIFT_EXPR, SImode, part2,
  554.             build_int_2 (bitsize_1, 0), 0, 1);
  555. #endif
  556.  
  557.   /* Combine the two parts with bitwise or.  This works
  558.      because we extracted both parts as unsigned bit fields.  */
  559.   result = expand_binop (SImode, ior_optab, part1, part2, 0, 1,
  560.              OPTAB_LIB_WIDEN);
  561.  
  562.   /* Unsigned bit field: we are done.  */
  563.   if (unsignedp)
  564.     return result;
  565.   /* Signed bit field: sign-extend with two arithmetic shifts.  */
  566.   result = expand_shift (LSHIFT_EXPR, SImode, result,
  567.              build_int_2 (BITS_PER_WORD - bitsize, 0), 0, 0);
  568.   return expand_shift (RSHIFT_EXPR, SImode, result,
  569.                build_int_2 (BITS_PER_WORD - bitsize, 0), 0, 0);
  570. }
  571.  
  572. /* Add INC into TARGET.  */
  573.  
  574. void
  575. expand_inc (target, inc)
  576.      rtx target, inc;
  577. {
  578.   rtx value = expand_binop (GET_MODE (target), add_optab,
  579.                 target, inc,
  580.                 target, 0, OPTAB_LIB_WIDEN);
  581.   if (value != target)
  582.     emit_move_insn (target, value);
  583. }
  584.  
  585. /* Subtract INC from TARGET.  */
  586.  
  587. void
  588. expand_dec (target, dec)
  589.      rtx target, dec;
  590. {
  591.   rtx value = expand_binop (GET_MODE (target), sub_optab,
  592.                 target, dec,
  593.                 target, 0, OPTAB_LIB_WIDEN);
  594.   if (value != target)
  595.     emit_move_insn (target, value);
  596. }
  597.  
  598. /* Output a shift instruction for expression code CODE,
  599.    with SHIFTED being the rtx for the value to shift,
  600.    and AMOUNT the tree for the amount to shift by.
  601.    Store the result in the rtx TARGET, if that is convenient.
  602.    If UNSIGNEDP is nonzero, do a logical shift; otherwise, arithmetic.
  603.    Return the rtx for where the value is.  */
  604.  
  605. /* Pastel, for shifts, converts shift count to SImode here
  606.    independent of the mode being shifted.
  607.    Should that be done in an earlier pass?
  608.    It turns out not to matter for C.  */
  609.  
  610. rtx
  611. expand_shift (code, mode, shifted, amount, target, unsignedp)
  612.      enum tree_code code;
  613.      register enum machine_mode mode;
  614.      rtx shifted;
  615.      tree amount;
  616.      register rtx target;
  617.      int unsignedp;
  618. {
  619.   register rtx op1, temp = 0;
  620.   register int left = (code == LSHIFT_EXPR || code == LROTATE_EXPR);
  621.   int try;
  622.   int rotate = code == LROTATE_EXPR || code == RROTATE_EXPR;
  623.   rtx last;
  624.  
  625.   /* Previously detected shift-counts computed by NEGATE_EXPR
  626.      and shifted in the other direction; but that does not work
  627.      on all machines.  */
  628.  
  629.   op1 = expand_expr (amount, 0, VOIDmode, 0);
  630.  
  631.   last = get_last_insn ();
  632.  
  633.   for (try = 0; temp == 0 && try < 3; try++)
  634.     {
  635.       enum optab_methods methods;
  636.       delete_insns_since (last);
  637.  
  638.       if (try == 0)
  639.     methods = OPTAB_DIRECT;
  640.       else if (try == 1)
  641.     methods = OPTAB_WIDEN;
  642.       else
  643.     methods = OPTAB_LIB_WIDEN;
  644.  
  645.       if (rotate)
  646.     {
  647.       /* Widening does not work for rotation.  */
  648.       if (methods != OPTAB_DIRECT)
  649.         methods = OPTAB_LIB;
  650.  
  651.       temp = expand_binop (mode,
  652.                    left ? rotl_optab : rotr_optab,
  653.                    shifted, op1, target, -1, methods);
  654.     }
  655.       else if (unsignedp)
  656.     {
  657.       temp = expand_binop (mode,
  658.                    left ? lshl_optab : lshr_optab,
  659.                    shifted, op1, target, unsignedp, methods);
  660.       if (temp == 0 && left)
  661.         temp = expand_binop (mode, ashl_optab,
  662.                  shifted, op1, target, unsignedp, methods);
  663.       if (temp != 0)
  664.         return temp;
  665.     }
  666.       /* Do arithmetic shifts.
  667.      Also, if we are going to widen the operand, we can just as well
  668.      use an arithmetic right-shift instead of a logical one.  */
  669.       if (! rotate && (! unsignedp || (! left && methods == OPTAB_WIDEN)))
  670.     {
  671.       enum optab_methods methods1 = methods;
  672.  
  673.       /* If trying to widen a log shift to an arithmetic shift,
  674.          don't accept an arithmetic shift of the same size.  */
  675.       if (unsignedp)
  676.         methods1 = OPTAB_MUST_WIDEN;
  677.  
  678.       /* Arithmetic shift */
  679.  
  680.       temp = expand_binop (mode,
  681.                    left ? ashl_optab : ashr_optab,
  682.                    shifted, op1, target, unsignedp, methods1);
  683.       if (temp != 0)
  684.         return temp;
  685.     }
  686.  
  687.       if (unsignedp)
  688.     {
  689.       /* No logical shift insn in either direction =>
  690.          try a bit-field extract instruction if we have one.  */
  691. #ifdef HAVE_extzv
  692. #ifndef BITS_BIG_ENDIAN
  693.       if (HAVE_extzv && !left
  694.           && ((methods == OPTAB_DIRECT && mode == SImode)
  695.           || (methods == OPTAB_WIDEN
  696.               && GET_MODE_SIZE (mode) < GET_MODE_SIZE (SImode))))
  697.         {
  698.           rtx shifted1 = convert_to_mode (SImode, shifted, 1);
  699.           rtx target1 = target;
  700.  
  701.           /* If -fforce-mem, don't let the operand be in memory.  */
  702.           if (flag_force_mem && GET_CODE (shifted1) == MEM)
  703.         shifted1 = force_not_mem (shifted1);
  704.  
  705.           /* If this machine's extzv insists on a register for
  706.          operand 1, arrange for that.  */
  707.           if (! ((*insn_operand_predicate[(int) CODE_FOR_extzv][1])
  708.              (shifted1, SImode)))
  709.         shifted1 = force_reg (SImode, shifted1);
  710.  
  711.           /* If we don't have or cannot use a suggested target,
  712.          make a place for the result, in the proper mode.  */
  713.           if (methods == OPTAB_WIDEN || target1 == 0
  714.           || ! ((*insn_operand_predicate[(int) CODE_FOR_extzv][0])
  715.             (target1, SImode)))
  716.         target1 = gen_reg_rtx (SImode);
  717.  
  718.           op1 = convert_to_mode (SImode, op1, 0);
  719.  
  720.           /* If this machine's extzv insists on a register for
  721.          operand 3, arrange for that.  */
  722.           if (! ((*insn_operand_predicate[(int) CODE_FOR_extzv][3])
  723.              (op1, SImode)))
  724.         op1 = force_reg (SImode, op1);
  725.  
  726.           op1 = protect_from_queue (op1, 1);
  727.  
  728.           /* TEMP gets the width of the bit field to extract:
  729.          wordsize minus # bits to shift by.  */
  730.           if (GET_CODE (op1) == CONST_INT)
  731.         temp = gen_rtx (CONST_INT, VOIDmode,
  732.                 (GET_MODE_BITSIZE (mode) - INTVAL (op1)));
  733.           else
  734.         temp = expand_binop (SImode, sub_optab,
  735.                      gen_rtx (CONST_INT, VOIDmode,
  736.                           GET_MODE_BITSIZE (mode)),
  737.                      op1, gen_reg_rtx (SImode),
  738.                      0, OPTAB_LIB_WIDEN);
  739.           /* Now extract with width TEMP, omitting OP1 least sig bits.  */
  740.           emit_insn (gen_extzv (protect_from_queue (target1, 1),
  741.                     protect_from_queue (shifted1, 0),
  742.                     temp, op1));
  743.           return convert_to_mode (mode, target1, 1);
  744.         }
  745.       /* Can also do logical shift with signed bit-field extract
  746.          followed by inserting the bit-field at a different position.
  747.          That strategy is not yet implemented.  */
  748. #endif /* not BITS_BIG_ENDIAN */
  749. #endif /* HAVE_extzv */
  750.       /* We have failed to generate the logical shift and will abort.  */
  751.     }
  752.     }
  753.   if (temp == 0)
  754.     abort ();
  755.   return temp;
  756. }
  757.  
  758. /* Output an instruction or two to bitwise-and OP0 with OP1
  759.    in mode MODE, with output to TARGET if convenient and TARGET is not zero.
  760.    Returns where the result is.  */
  761. /* This function used to do more; now it could be eliminated.  */
  762.  
  763. rtx
  764. expand_bit_and (mode, op0, op1, target)
  765.      enum machine_mode mode;
  766.      rtx op0, op1, target;
  767. {
  768.   register rtx temp;
  769.  
  770.   /* First try to open-code it directly.  */
  771.   temp = expand_binop (mode, and_optab, op0, op1, target, 1, OPTAB_LIB_WIDEN);
  772.   if (temp == 0)
  773.     abort ();
  774.   return temp;
  775. }
  776.  
  777. /* Perform a multiplication and return an rtx for the result.
  778.    MODE is mode of value; OP0 and OP1 are what to multiply (rtx's);
  779.    TARGET is a suggestion for where to store the result (an rtx).
  780.  
  781.    We check specially for a constant integer as OP1.
  782.    If you want this check for OP0 as well, then before calling
  783.    you should swap the two operands if OP0 would be constant.  */
  784.  
  785. rtx
  786. expand_mult (mode, op0, op1, target, unsignedp)
  787.      enum machine_mode mode;
  788.      register rtx op0, op1, target;
  789.      int unsignedp;
  790. {
  791.   /* Don't use the function value register as a target
  792.      since we have to read it as well as write it,
  793.      and function-inlining gets confused by this.  */
  794.   if (target && REG_P (target) && REG_FUNCTION_VALUE_P (target))
  795.     target = 0;
  796.  
  797.   if (GET_CODE (op1) == CONST_INT)
  798.     {
  799.       register int foo;
  800.       int bar;
  801.       int negate = INTVAL (op1) < 0;
  802.       int absval = INTVAL (op1) * (negate ? -1 : 1);
  803.  
  804.       /* Is multiplier a power of 2, or minus that?  */
  805.       foo = exact_log2 (absval);
  806.       if (foo >= 0)
  807.     {
  808.       rtx tem;
  809.       if (foo == 0)
  810.         tem = op0;
  811.       else
  812.         tem = expand_shift (LSHIFT_EXPR, mode, op0,
  813.                 build_int_2 (foo, 0),
  814.                 target, 0);
  815.       return (negate
  816.           ? expand_unop (mode, neg_optab, tem, target, 0)
  817.           : tem);
  818.     }
  819.       /* Is multiplier a sum of two powers of 2, or minus that?  */
  820.       bar = floor_log2 (absval);
  821.       foo = exact_log2 (absval - (1 << bar));
  822.       if (bar >= 0 && foo >= 0)
  823.     {
  824.       rtx tem =
  825.         force_operand (gen_rtx (PLUS, mode,
  826.                     expand_shift (LSHIFT_EXPR, mode, op0,
  827.                              build_int_2 (bar - foo, 0),
  828.                              0, 0),
  829.                     op0),
  830.                ((foo == 0 && ! negate) ? target : 0));
  831.  
  832.       if (foo != 0)
  833.         tem = expand_shift (LSHIFT_EXPR, mode, tem,
  834.                 build_int_2 (foo, 0),
  835.                 negate ? 0 : target, 0);
  836.  
  837.       return negate ? expand_unop (mode, neg_optab, tem, target, 0) : tem;
  838.     }
  839.     }
  840.   /* This used to use umul_optab if unsigned,
  841.      but I think that for non-widening multiply there is no difference
  842.      between signed and unsigned.  */
  843.   op0 = expand_binop (mode, smul_optab,
  844.               op0, op1, target, unsignedp, OPTAB_LIB_WIDEN);
  845.   if (op0 == 0)
  846.     abort ();
  847.   return op0;
  848. }
  849.  
  850. /* Emit the code to divide OP0 by OP1, putting the result in TARGET
  851.    if that is convenient, and returning where the result is.
  852.    You may request either the quotient or the remainder as the result;
  853.    specify REM_FLAG nonzero to get the remainder.
  854.  
  855.    CODE is the expression code for which kind of division this is;
  856.    it controls how rounding is done.  MODE is the machine mode to use.
  857.    UNSIGNEDP nonzero means do unsigned division.  */
  858.  
  859. /* ??? For CEIL_MOD_EXPR, can compute incorrect remainder with ANDI
  860.    and then correct it by or'ing in missing high bits
  861.    if result of ANDI is nonzero.
  862.    For ROUND_MOD_EXPR, can use ANDI and then sign-extend the result.
  863.    This could optimize to a bfexts instruction.
  864.    But C doesn't use these operations, so their optimizations are
  865.    left for later.  */
  866.  
  867. rtx
  868. expand_divmod (rem_flag, code, mode, op0, op1, target, unsignedp)
  869.      int rem_flag;
  870.      enum tree_code code;
  871.      enum machine_mode mode;
  872.      register rtx op0, op1, target;
  873.      int unsignedp;
  874. {
  875.   register rtx temp;
  876.   int log = -1;
  877.   int can_clobber_op0;
  878.   int mod_insn_no_good = 0;
  879.   rtx adjusted_op0 = op0;
  880.  
  881.   /* Don't use the function value register as a target
  882.      since we have to read it as well as write it,
  883.      and function-inlining gets confused by this.  */
  884.   if (target && REG_P (target) && REG_FUNCTION_VALUE_P (target))
  885.     target = 0;
  886.  
  887.   /* Don't clobber an operand while doing a multi-step calculation.  */
  888.   if (target)
  889.     if ((rem_flag && (reg_mentioned_p (target, op0)
  890.               || (GET_CODE (op0) == MEM && GET_CODE (target) == MEM)))
  891.     || reg_mentioned_p (target, op1)
  892.     || (GET_CODE (op1) == MEM && GET_CODE (target) == MEM))
  893.       target = 0;
  894.  
  895.   if (target == 0)
  896.     target = gen_reg_rtx (mode);
  897.  
  898.   can_clobber_op0 = (GET_CODE (op0) == REG && op0 == target);
  899.  
  900.   if (GET_CODE (op1) == CONST_INT)
  901.     log = exact_log2 (INTVAL (op1));
  902.  
  903.   /* If log is >= 0, we are dividing by 2**log, and will do it by shifting,
  904.      which is really floor-division.  Otherwise we will really do a divide,
  905.      and we assume that is trunc-division.
  906.  
  907.      We must correct the dividend by adding or subtracting something
  908.      based on the divisor, in order to do the kind of rounding specified
  909.      by CODE.  The correction depends on what kind of rounding is actually
  910.      available, and that depends on whether we will shift or divide.  */
  911.  
  912.   switch (code)
  913.     {
  914.     case TRUNC_MOD_EXPR:
  915.     case TRUNC_DIV_EXPR:
  916.       if (log >= 0 && ! unsignedp)
  917.     {
  918.       rtx label = gen_label_rtx ();
  919.       if (! can_clobber_op0)
  920.         adjusted_op0 = copy_to_suggested_reg (adjusted_op0, target);
  921.       emit_cmp_insn (adjusted_op0, const0_rtx, 0, 0, 0);
  922.       emit_jump_insn (gen_bge (label));
  923.       expand_inc (adjusted_op0, plus_constant (op1, -1));
  924.       emit_label (label);
  925.       mod_insn_no_good = 1;
  926.     }
  927.       break;
  928.  
  929.     case FLOOR_DIV_EXPR:
  930.     case FLOOR_MOD_EXPR:
  931.       if (log < 0 && ! unsignedp)
  932.     {
  933.       rtx label = gen_label_rtx ();
  934.       if (! can_clobber_op0)
  935.         adjusted_op0 = copy_to_suggested_reg (adjusted_op0, target);
  936.       emit_cmp_insn (adjusted_op0, const0_rtx, 0, 0, 0);
  937.       emit_jump_insn (gen_bge (label));
  938.       expand_dec (adjusted_op0, op1);
  939.       expand_inc (adjusted_op0, const1_rtx);
  940.       emit_label (label);
  941.       mod_insn_no_good = 1;
  942.     }
  943.       break;
  944.  
  945.     case CEIL_DIV_EXPR:
  946.     case CEIL_MOD_EXPR:
  947.       if (! can_clobber_op0)
  948.     adjusted_op0 = copy_to_suggested_reg (adjusted_op0, target);
  949.       if (log < 0)
  950.     {
  951.       rtx label = 0;
  952.       if (! unsignedp)
  953.         {
  954.           label = gen_label_rtx ();
  955.           emit_cmp_insn (adjusted_op0, const0_rtx, 0, 0, 0);
  956.           emit_jump_insn (gen_ble (label));
  957.         }
  958.       expand_inc (adjusted_op0, op1);
  959.       expand_dec (adjusted_op0, const1_rtx);
  960.       if (! unsignedp)
  961.         emit_label (label);
  962.     }
  963.       else
  964.     {
  965.       adjusted_op0 = expand_binop (GET_MODE (target), add_optab,
  966.                        adjusted_op0, plus_constant (op1, -1),
  967.                        0, 0, OPTAB_LIB_WIDEN);
  968.     }
  969.       mod_insn_no_good = 1;
  970.       break;
  971.  
  972.     case ROUND_DIV_EXPR:
  973.     case ROUND_MOD_EXPR:
  974.       if (! can_clobber_op0)
  975.     adjusted_op0 = copy_to_suggested_reg (adjusted_op0, target);
  976.       if (log < 0)
  977.     {
  978.       op1 = expand_shift (RSHIFT_EXPR, mode, op1, integer_one_node, 0, 0);
  979.       if (! unsignedp)
  980.         {
  981.           rtx label = gen_label_rtx ();
  982.           emit_cmp_insn (adjusted_op0, const0_rtx, 0, 0, 0);
  983.           emit_jump_insn (gen_bge (label));
  984.           expand_unop (mode, neg_optab, op1, op1, 0);
  985.           emit_label (label);
  986.         }
  987.       expand_inc (adjusted_op0, op1);
  988.     }
  989.       else
  990.     {
  991.       op1 = gen_rtx (CONST_INT, VOIDmode, INTVAL (op1) / 2);
  992.       expand_inc (adjusted_op0, op1);
  993.     }
  994.       mod_insn_no_good = 1;
  995.       break;
  996.     }
  997.  
  998.   if (rem_flag && !mod_insn_no_good)
  999.     {
  1000.       /* Try to produce the remainder directly */
  1001.       if (log >= 0)
  1002.     {
  1003.       return expand_bit_and (mode, adjusted_op0,
  1004.                  gen_rtx (CONST_INT, VOIDmode,
  1005.                       INTVAL (op1) - 1),
  1006.                  target);
  1007.     }
  1008.       else
  1009.     {
  1010.       /* See if we can do remainder without a library call.  */
  1011.       temp = sign_expand_binop (mode, umod_optab, smod_optab,
  1012.                     adjusted_op0, op1, target,
  1013.                     unsignedp, OPTAB_WIDEN);
  1014.       if (temp != 0)
  1015.         return temp;
  1016.       /* No luck there.
  1017.          Can we do remainder and divide at once without a library call?  */
  1018.       temp = gen_reg_rtx (mode);
  1019.       if (expand_twoval_binop (unsignedp ? udivmod_optab : sdivmod_optab,
  1020.                    adjusted_op0, op1,
  1021.                    0, temp, unsignedp))
  1022.         return temp;
  1023.       temp = 0;
  1024.     }
  1025.     }
  1026.  
  1027.   /* Produce the quotient.  */
  1028.   if (log >= 0)
  1029.     temp = expand_shift (RSHIFT_EXPR, mode, adjusted_op0,
  1030.              build_int_2 (exact_log2 (INTVAL (op1)), 0),
  1031.              target, unsignedp);
  1032.   else if (rem_flag && !mod_insn_no_good)
  1033.     /* If producing quotient in order to subtract for remainder,
  1034.        and a remainder subroutine would be ok,
  1035.        don't use a divide subroutine.  */
  1036.     temp = sign_expand_binop (mode, udiv_optab, sdiv_optab,
  1037.                   adjusted_op0, op1, target,
  1038.                   unsignedp, OPTAB_WIDEN);
  1039.   else
  1040.     temp = sign_expand_binop (mode, udiv_optab, sdiv_optab,
  1041.                   adjusted_op0, op1, target,
  1042.                   unsignedp, OPTAB_LIB_WIDEN);
  1043.  
  1044.   /* If we really want the remainder, get it by subtraction.  */
  1045.   if (rem_flag)
  1046.     {
  1047.       if (temp == 0)
  1048.     {
  1049.       /* No divide instruction either.  Use library for remainder.  */
  1050.       temp = sign_expand_binop (mode, umod_optab, smod_optab,
  1051.                     op0, op1, target,
  1052.                     unsignedp, OPTAB_LIB_WIDEN);
  1053.     }
  1054.       else
  1055.     {
  1056.       /* We divided.  Now finish doing X - Y * (X / Y).  */
  1057.       temp = expand_mult (mode, temp, op1, temp, unsignedp);
  1058.       if (! temp) abort ();
  1059.       temp = expand_binop (mode, sub_optab, op0,
  1060.                    temp, target, unsignedp, OPTAB_LIB_WIDEN);
  1061.     }
  1062.     }
  1063.  
  1064.   if (temp == 0)
  1065.     abort ();
  1066.   return temp;
  1067. }
  1068.  
  1069. /* Return a tree node with data type TYPE, describing the value of X.
  1070.    Usually this is an RTL_EXPR, if there is no obvious better choice.  */
  1071.  
  1072. static tree
  1073. make_tree (type, x)
  1074.      tree type;
  1075.      rtx x;
  1076. {
  1077.   tree t;
  1078.   switch (GET_CODE (x))
  1079.     {
  1080.     case CONST_INT:
  1081.       t = build_int_2 (INTVAL (x), 0);
  1082.       TREE_TYPE (t) = type;
  1083.       return fold (t);
  1084.  
  1085.     default:
  1086.       t = make_node (RTL_EXPR);
  1087.       TREE_TYPE (t) = type;
  1088.       RTL_EXPR_RTL (t) = x;
  1089.       /* There are no insns to be output
  1090.      when this rtl_expr is used.  */
  1091.       RTL_EXPR_SEQUENCE (t) = 0;
  1092.       return t;
  1093.     }
  1094. }
  1095.  
  1096. /* Return an rtx representing the value of X * MULT + ADD.
  1097.    MODE is the machine mode for the computation.
  1098.    UNSIGNEDP is non-zero to do unsigned multiplication.
  1099.    This may emit insns.  */
  1100.  
  1101. rtx
  1102. expand_mult_add (x, mult, add, mode, unsignedp)
  1103.      rtx x, mult, add;
  1104.      enum machine_mode mode;
  1105.      int unsignedp;
  1106. {
  1107.   tree type = type_for_size (GET_MODE_BITSIZE (mode), unsignedp);
  1108.   tree prod = fold (build (MULT_EXPR, type, make_tree (type, x),
  1109.                make_tree (type, mult)));
  1110.   tree sum = fold (build (PLUS_EXPR, type, prod, make_tree (type, add)));
  1111.   return expand_expr (sum, 0, VOIDmode, 0);
  1112. }
  1113.